package com.jumi.microservice.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jumi.microservice.domain.ImageSpaceDO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 商城相册图片表 Mapper 接口
 * </p>
 *
 * @author liuz
 * @since 2020-07-27
 */
public interface ImageSpaceMapper extends BaseMapper<ImageSpaceDO> {

    @Select("<script> select \n" +
            "a.photo_album_id photoAlbumId, a.image_cover, count(a.photo_album_id) imageSize \n" +
            "from (\n" +
            "\tselect id,image_name,photo_album_id,image_cover,image_size,image_spec,\n" +
            "\tupload_time,creater,create_time,modifier,update_time\n" +
            "\tfrom commodity_image_space\n" +
            "\t where photo_album_id in "+
            "<foreach collection='ids' item='id' open='(' separator=',' close=')'>"+
                "#{id}"+
            "</foreach>"+
            "\torder by create_time desc \n" +
            ")a \n" +
            "GROUP BY photo_album_id " +
            "</script>")
    List<ImageSpaceDO> selectList4Cover(@Param("ids")List<Long> pid);
}
